<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Default -- 预设值 | Ted Yuen的技术博客</title>
    <meta name="description" content="BrE /dɪ&#39;fɔlt/ ; AmE /dɪ&#39;fɔlt/

n.违约(尤指未偿付债务);默认;系统设定值;预置值
v.违约;不履行义务(尤指不偿还债务);默认;预设;预置

栗子

一、 阻止默认事件

event.preventDefault();

&gt; 该方法将通知 Web 浏览器不要执行与事件关联的默认动作（如果存在这样的动作）。例如 ...">
    <meta name="generator" content="VuePress 1.4.0">
    
    
    <link rel="preload" href="/assets/css/0.styles.b6e5dee4.css" as="style"><link rel="preload" href="/assets/js/app.a5c0d474.js" as="script"><link rel="preload" href="/assets/js/15.57df9f8e.js" as="script"><link rel="preload" href="/assets/js/30.191f3008.js" as="script"><link rel="prefetch" href="/assets/js/10.262e0963.js"><link rel="prefetch" href="/assets/js/11.03a057c9.js"><link rel="prefetch" href="/assets/js/12.63659604.js"><link rel="prefetch" href="/assets/js/13.0549c43a.js"><link rel="prefetch" href="/assets/js/14.e794c180.js"><link rel="prefetch" href="/assets/js/16.a0d9468b.js"><link rel="prefetch" href="/assets/js/17.06d3e00b.js"><link rel="prefetch" href="/assets/js/18.0d80b21a.js"><link rel="prefetch" href="/assets/js/19.1e9da99b.js"><link rel="prefetch" href="/assets/js/20.08d3d7c6.js"><link rel="prefetch" href="/assets/js/21.b1aee962.js"><link rel="prefetch" href="/assets/js/22.4f410a60.js"><link rel="prefetch" href="/assets/js/23.6d06a125.js"><link rel="prefetch" href="/assets/js/24.f7a70963.js"><link rel="prefetch" href="/assets/js/25.5ee1e916.js"><link rel="prefetch" href="/assets/js/26.7bdc3bcf.js"><link rel="prefetch" href="/assets/js/27.15c6e05a.js"><link rel="prefetch" href="/assets/js/28.ae822034.js"><link rel="prefetch" href="/assets/js/29.170e7a57.js"><link rel="prefetch" href="/assets/js/3.d6f86d84.js"><link rel="prefetch" href="/assets/js/31.5175acc4.js"><link rel="prefetch" href="/assets/js/32.73255ebc.js"><link rel="prefetch" href="/assets/js/33.203b8fc2.js"><link rel="prefetch" href="/assets/js/4.a2169bd0.js"><link rel="prefetch" href="/assets/js/5.894072dc.js"><link rel="prefetch" href="/assets/js/6.f66a1900.js"><link rel="prefetch" href="/assets/js/7.cbb4d687.js"><link rel="prefetch" href="/assets/js/8.d2217048.js"><link rel="prefetch" href="/assets/js/9.0d6d3c54.js"><link rel="prefetch" href="/assets/js/vuejs-paginate.643397bf.js">
    <link rel="stylesheet" href="/assets/css/0.styles.b6e5dee4.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-c305a0ca><header class="navbar" data-v-c305a0ca><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">Ted Yuen的技术博客</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">
  博文
</a></div><div class="nav-item"><a href="/tag/" class="nav-link">
  标签云
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="专栏" class="dropdown-title"><span class="title">专栏</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/tag/Vocabulary/" class="nav-link">
  程序员英语词汇
</a></li></ul></div></div><div class="nav-item"><a href="https://github.com/tedyuen" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-c305a0ca></div> <aside class="sidebar" data-v-c305a0ca><nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">
  博文
</a></div><div class="nav-item"><a href="/tag/" class="nav-link">
  标签云
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="专栏" class="dropdown-title"><span class="title">专栏</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/tag/Vocabulary/" class="nav-link">
  程序员英语词汇
</a></li></ul></div></div><div class="nav-item"><a href="https://github.com/tedyuen" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav>  <!----> </aside> <div data-v-c305a0ca><main class="page"> <article class="theme-default-content"><header><h1 itemprop="name headline" class="post-title">
        Default -- 预设值
      </h1> <div class="post-meta"><div itemprop="publisher author" itemtype="http://schema.org/Person" itemscope="itemscope" class="post-meta-author"><svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-navigation"><polygon points="3 11 22 2 13 21 11 13 3 11"></polygon></svg> <span itemprop="name">Ted Yuen</span> <span itemprop="address">   in Shanghai</span></div> <div class="post-meta-date"><svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg> <time pubdate itemprop="datePublished" datetime="2020-06-01T00:00:00.000Z">
      Mon Jun 01 2020
    </time></div> <ul itemprop="keywords" class="post-meta-tags"><li class="post-tag" data-v-6958873e><a href="/tag/Vocabulary" data-v-6958873e> Vocabulary </a></li></ul></div></header> <div class="content__default"><p><strong>BrE</strong> /dɪ'fɔlt/ ; <strong>AmE</strong> /dɪ'fɔlt/</p> <ol><li>n.违约(尤指未偿付债务);默认;系统设定值;预置值</li> <li>v.违约;不履行义务(尤指不偿还债务);默认;预设;预置</li></ol> <h3 id="栗子"><a href="#栗子" class="header-anchor">#</a> 栗子</h3> <p>一、 阻止默认事件</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>event<span class="token punctuation">.</span><span class="token function">preventDefault</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><blockquote><p>该方法将通知 Web 浏览器不要执行与事件关联的默认动作（如果存在这样的动作）。例如，如果 type 属性是 &quot;submit&quot;，在事件传播的任意阶段可以调用任意的事件句柄，通过调用该方法，可以阻止提交表单。注意，如果 Event 对象的 cancelable 属性是 fasle，那么就没有默认动作，或者不能阻止默认动作。无论哪种情况，调用该方法都没有作用。</p></blockquote> <p>二、Sass指定变量默认值</p> <div class="language-css line-numbers-mode"><pre class="language-css"><code><span class="token property">color</span><span class="token punctuation">:</span> #fff !default<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><blockquote><p>If the value assigned to a variable is followed by a !defaultflag, this means that if the variable has already been assigned, it will not be reassigned, but if it has not already been assigned, then it will be assigned a new given value.
可以在变量的结尾添加 !default 给一个未通过 !default 声明赋值的变量赋值，此时，如果变量已经被赋值，不会再被重新赋值，但是如果变量还没有被赋值，则会被赋予新的值。</p></blockquote> <p>三、大部分语言的默认值</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token comment"># SQL</span>
<span class="token punctuation">`</span>CONNENT<span class="token punctuation">`</span> <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">256</span><span class="token punctuation">)</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span> utf8 <span class="token keyword">DEFAULT</span> <span class="token boolean">NULL</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">// ES6 modules</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token constant">XXXX</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token comment">// switch case中的default</span>
<span class="token keyword">switch</span><span class="token punctuation">(</span>num<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">case</span> <span class="token number">0</span><span class="token operator">:</span> xxx<span class="token punctuation">;</span><span class="token keyword">break</span><span class="token punctuation">;</span>
  <span class="token keyword">case</span> <span class="token number">1</span><span class="token operator">:</span> xxx<span class="token punctuation">;</span><span class="token keyword">break</span><span class="token punctuation">;</span>
  <span class="token keyword">default</span><span class="token operator">:</span> xxx<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="最后"><a href="#最后" class="header-anchor">#</a> 最后</h3> <p>大家可能会嘲笑我今天把这个单词拿出来。哪怕是个编程小白，在写出Hello World之后最多不超过1个礼拜就会认识这个单词。而且会成为熟练度仅次于<code>public</code>的一员。</p> <p>那我今天要和大家分享的是当我在另外一个地方见到他，发现了另一个释义以后，对这个单词豁然开朗的感觉。</p> <p>电影《大空头》(顺便强烈推荐这部电影)中频繁出现的一个缩写--CDS(Credit Default Swap)，信用违约互换。当<code>Default</code>这个单词翻译成违约的时候，大家细细品。程序中我们假设约定了一组设定，当没有命中任何一种的时候，触发default，是不是就是默认值的意思呢？好了，不多说，大家自己细细品。翻译尽量不要去直译，任何语言都是这样，当你从心底理解这个单词，就能更好地去使用它了。</p></div> <footer class="page-edit"><!----> <!----></footer> <!----> <div class="vocabulary"><div>关注公众号【程序员英语词汇】获取最新内容</div> <img src="/images/wechat.jpg" alt="程序员英语词汇"></div></article> </main></div> <footer data-v-c305a0ca>Copyright © 2020 Ted Yuen</footer></div><div class="global-ui"><!----></div></div>
    <script src="/assets/js/app.a5c0d474.js" defer></script><script src="/assets/js/15.57df9f8e.js" defer></script><script src="/assets/js/30.191f3008.js" defer></script>
  </body>
</html>
